<?php

class page
{

	function printTop()
	{
?><!DOCTYPE html><html><head>
<title>微客读 - 分享精彩瞬间</title>

<meta http-equiv="content-type" content="text/html;charset=utf-8">
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />

<script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.7.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
<!--script type="text/javascript" src="/js/jquery.blockUI.js"></script-->
<script type="text/javascript" src="/js/jquery.jgrowl.js"></script>
<script type="text/javascript" src="/js/date.js"></script>
<script type="text/javascript" src="/js/jquery.datePicker.js"></script>
<script type="text/javascript" src="/js/jquery.datePickerMultiMonth.js"></script>
<script type="text/javascript" src="/js/fileuploader.js"></script>
<script type="text/javascript" src="/js/weekdo.js"></script>

<link rel="stylesheet" type="text/css" media="screen" href="/css/jquery-ui-1.8.7.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/datePicker.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/jquery.jgrowl.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/fileuploader.css" />

<script type="text/javascript" charset="utf-8">
Date.firstDayOfWeek = 0;
Date.format = 'yyyy-mm-dd';
$.dpText = {
	TEXT_PREV_YEAR		:	'上年',
	TEXT_PREV_MONTH		:	'上月',
	TEXT_NEXT_YEAR		:	'下年',
	TEXT_NEXT_MONTH		:	'下月',
	TEXT_CLOSE			:	'关闭',
	TEXT_CHOOSE_DATE	:	'选择日期'
}

$(function($) {
	logout = function()
	{
		document.location.href='/logout/';
	}
});

</script>

</head>
<body>
<?php
		page::printLogin();
		page::showMenuIfLogged();
	}
	
	function printTail()
	{
?>
<div style="float:left;width:100%;padding-top:30px;"><hr />
<div style="color:#888;text-align:center;padding-bottom:10px;">weekdo.com @ 2011 - by <a href="mailto:mail.langrui@gmail.com">Solomon</a></div>
</div></body></html>
<?php
	}

	function showMenuIfLogged()
	{
		if (user::isLogged())
		{
?>
<div class=menu>
<a class=menu_item href=/><img src="/images/home.png" />首页</a>
<a class=menu_item href=/playground/><img src="/images/playground.jpg" />图片广场</a>
<a class=menu_item href=/additem/><img src="/images/itemadd.png" />发表图博</a>
<a class=menu_item href=/user/<?php echo user::getId(); ?>/itemtroop/><img src="/images/user_me.png" />我的图博</a>
<!--a class=menu_item href=/settings/><img src="/images/settings.png" />我的设置</a>
<a class=menu_item href=/><img src="/images/followees.png" /> 我关注的</a>
<a class=menu_item href=/><img src="/images/followers.png" /> 关注我的</a>
<input class="menu_item search_box" /><input class="search_button" type="image" src="/images/search.png" /-->
<a class="menu_item help" href=/about/>关于 <img src="/images/help.png" /></a>
</div>
<?php
		}
		else
		{
?>
<div class=menu>
<a class=menu_item href=/><img src="/images/home.png" />首页</a>
<a class=menu_item href=/playground/><img src="/images/playground.jpg" />图片广场</a>
<a class=menu_item href=/register/><img src="/images/magicstick.png" />注册</a>
<!--input class="menu_item search_box" /><input class="search_button" type="image" src="/images/search.png" /-->
<a class="menu_item help" href=/about/><img src="/images/help.png" />关于</a>
</div>
<?php
		}
	}

	function printLogin()
	{
		echo '<div><a href=/><img src=/images/logo.jpg /></a>';
		if (user::isLogged())
		{
			echo "<div style='float:right;margin-top:40px;'>亲爱的 "
				."<a href='/user/".$_COOKIE['user_id']."/'>".$_COOKIE['user_nickname']."</a>"
				."，欢迎回来！ <input type=button onclick='document.location.href=/additem/' value='发表图博' /> "
				."<input id=button_quit type=button onclick='logout()' value='退出' /></div><br>";
		} else {
		?>
			<form method=post style="float:right; margin-top:40px;">
			登录：<input name="login" value="<?php echo $_COOKIE['user_nickname']?$_COOKIE['user_nickname']:'请输入昵称或Email'; ?>" onclick="this.value=''" /> 
			密码：<input type="password" name="passwd" /> 
			<input type="submit" value="我回来啦~" />
			</form>
			<a href="/register/" style="float:right;margin-right:100px;margin-top:30px;"><img src="/images/magicstick.png" /> 注册成为用户</a>
		<?php
		}
		echo '</div>';
	}
}

?>
